import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { fetchRegistration } from './auth.actions';

const initialState = {
	user: {},
	loading: false,
	error: null,
	success: false
};

export const userRegistrationSlice = createSlice({
	name: 'userRegistration',
	initialState,
	reducers: {},
	extraReducers: (builder) => {
		builder.addCase(fetchRegistration.pending, (state) => {
			state.loading = true;
			state.error = null;
		}),
		builder.addCase(fetchRegistration.fulfilled, (state, action) => {
			console.log('данные после регистрации', action.payload);
			// state.user = action.payload
		}),
		builder.addCase(fetchRegistration.rejected, (state, action) => {
			state.error = action.error.message;
		});
	}
});
